﻿#region << 版 本 注 释 >>
/*----------------------------------------------------------------
 * 版权所有 (c) 2022 北京超维景生物科技有限公司 保留所有权利。
 * 
 * 创建者：huangyang
 * 电子邮箱：huangyang@tvscope.cn
 * 创建时间：2023/2/23 9:51:26
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/
#endregion << 版 本 注 释 >>

using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImageK.Java
{
    public interface Shape
    {
        /**
         * Returns an integer {@link Rectangle} that completely encloses the
         * {@code Shape}.  Note that there is no guarantee that the
         * returned {@code Rectangle} is the smallest bounding box that
         * encloses the {@code Shape}, only that the {@code Shape}
         * lies entirely within the indicated  {@code Rectangle}.  The
         * returned {@code Rectangle} might also fail to completely
         * enclose the {@code Shape} if the {@code Shape} overflows
         * the limited range of the integer data type.  The
         * {@code getBounds2D} method generally returns a
         * tighter bounding box due to its greater flexibility in
         * representation.
         *
         * <p>
         * Note that the <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
         * definition of insideness</a> can lead to situations where points
         * on the defining outline of the {@code shape} may not be considered
         * contained in the returned {@code bounds} object, but only in cases
         * where those points are also not considered contained in the original
         * {@code shape}.
         * </p>
         * <p>
         * If a {@code point} is inside the {@code shape} according to the
         * {@link #contains(double x, double y) contains(point)} method, then
         * it must be inside the returned {@code Rectangle} bounds object
         * according to the {@link #contains(double x, double y) contains(point)}
         * method of the {@code bounds}. Specifically:
         * </p>
         * <p>
         *  {@code shape.contains(x,y)} requires {@code bounds.contains(x,y)}
         * </p>
         * <p>
         * If a {@code point} is not inside the {@code shape}, then it might
         * still be contained in the {@code bounds} object:
         * </p>
         * <p>
         *  {@code bounds.contains(x,y)} does not imply {@code shape.contains(x,y)}
         * </p>
         * @return an integer {@code Rectangle} that completely encloses
         *                 the {@code Shape}.
         * @see #getBounds2D
         * @since 1.2
         */
        Rectangle getBounds();

        /**
         * Returns a high precision and more accurate bounding box of
         * the {@code Shape} than the {@code getBounds} method.
         * Note that there is no guarantee that the returned
         * {@link Rectangle2D} is the smallest bounding box that encloses
         * the {@code Shape}, only that the {@code Shape} lies
         * entirely within the indicated {@code Rectangle2D}.  The
         * bounding box returned by this method is usually tighter than that
         * returned by the {@code getBounds} method and never fails due
         * to overflow problems since the return value can be an instance of
         * the {@code Rectangle2D} that uses double precision values to
         * store the dimensions.
         *
         * <p>
         * Note that the <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
         * definition of insideness</a> can lead to situations where points
         * on the defining outline of the {@code shape} may not be considered
         * contained in the returned {@code bounds} object, but only in cases
         * where those points are also not considered contained in the original
         * {@code shape}.
         * </p>
         * <p>
         * If a {@code point} is inside the {@code shape} according to the
         * {@link #contains(Point2D p) contains(point)} method, then it must
         * be inside the returned {@code Rectangle2D} bounds object according
         * to the {@link #contains(Point2D p) contains(point)} method of the
         * {@code bounds}. Specifically:
         * </p>
         * <p>
         *  {@code shape.contains(p)} requires {@code bounds.contains(p)}
         * </p>
         * <p>
         * If a {@code point} is not inside the {@code shape}, then it might
         * still be contained in the {@code bounds} object:
         * </p>
         * <p>
         *  {@code bounds.contains(p)} does not imply {@code shape.contains(p)}
         * </p>
         * @return an instance of {@code Rectangle2D} that is a
         *                 high-precision bounding box of the {@code Shape}.
         * @see #getBounds
         * @since 1.2
         */
        public RectangleF getBounds2D();

        /**
         * Tests if the specified coordinates are inside the boundary of the
         * {@code Shape}, as described by the
         * <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
         * definition of insideness</a>.
         * @param x the specified X coordinate to be tested
         * @param y the specified Y coordinate to be tested
         * @return {@code true} if the specified coordinates are inside
         *         the {@code Shape} boundary; {@code false}
         *         otherwise.
         * @since 1.2
         */
        bool contains(double x, double y);

        /**
         * Tests if a specified {@link Point2D} is inside the boundary
         * of the {@code Shape}, as described by the
         * <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
         * definition of insideness</a>.
         * @param p the specified {@code Point2D} to be tested
         * @return {@code true} if the specified {@code Point2D} is
         *          inside the boundary of the {@code Shape};
         *          {@code false} otherwise.
         * @since 1.2
         */
        public bool contains(PointF p);

        /**
         * Tests if the interior of the {@code Shape} intersects the
         * interior of a specified rectangular area.
         * The rectangular area is considered to intersect the {@code Shape}
         * if any point is contained in both the interior of the
         * {@code Shape} and the specified rectangular area.
         * <p>
         * The {@code Shape.intersects()} method allows a {@code Shape}
         * implementation to conservatively return {@code true} when:
         * <ul>
         * <li>
         * there is a high probability that the rectangular area and the
         * {@code Shape} intersect, but
         * <li>
         * the calculations to accurately determine this intersection
         * are prohibitively expensive.
         * </ul>
         * This means that for some {@code Shapes} this method might
         * return {@code true} even though the rectangular area does not
         * intersect the {@code Shape}.
         * The {@link java.awt.geom.Area Area} class performs
         * more accurate computations of geometric intersection than most
         * {@code Shape} objects and therefore can be used if a more precise
         * answer is required.
         *
         * @param x the X coordinate of the upper-left corner
         *          of the specified rectangular area
         * @param y the Y coordinate of the upper-left corner
         *          of the specified rectangular area
         * @param w the width of the specified rectangular area
         * @param h the height of the specified rectangular area
         * @return {@code true} if the interior of the {@code Shape} and
         *          the interior of the rectangular area intersect, or are
         *          both highly likely to intersect and intersection calculations
         *          would be too expensive to perform; {@code false} otherwise.
         * @see java.awt.geom.Area
         * @since 1.2
         */
        public bool intersects(double x, double y, double w, double h);

        /**
         * Tests if the interior of the {@code Shape} intersects the
         * interior of a specified {@code Rectangle2D}.
         * The {@code Shape.intersects()} method allows a {@code Shape}
         * implementation to conservatively return {@code true} when:
         * <ul>
         * <li>
         * there is a high probability that the {@code Rectangle2D} and the
         * {@code Shape} intersect, but
         * <li>
         * the calculations to accurately determine this intersection
         * are prohibitively expensive.
         * </ul>
         * This means that for some {@code Shapes} this method might
         * return {@code true} even though the {@code Rectangle2D} does not
         * intersect the {@code Shape}.
         * The {@link java.awt.geom.Area Area} class performs
         * more accurate computations of geometric intersection than most
         * {@code Shape} objects and therefore can be used if a more precise
         * answer is required.
         *
         * @param r the specified {@code Rectangle2D}
         * @return {@code true} if the interior of the {@code Shape} and
         *          the interior of the specified {@code Rectangle2D}
         *          intersect, or are both highly likely to intersect and intersection
         *          calculations would be too expensive to perform; {@code false}
         *          otherwise.
         * @see #intersects(double, double, double, double)
         * @since 1.2
         */
        public bool intersects(Rectangle2D r);

        /**
         * Tests if the interior of the {@code Shape} entirely contains
         * the specified rectangular area.  All coordinates that lie inside
         * the rectangular area must lie within the {@code Shape} for the
         * entire rectangular area to be considered contained within the
         * {@code Shape}.
         * <p>
         * The {@code Shape.contains()} method allows a {@code Shape}
         * implementation to conservatively return {@code false} when:
         * <ul>
         * <li>
         * the {@code intersect} method returns {@code true} and
         * <li>
         * the calculations to determine whether or not the
         * {@code Shape} entirely contains the rectangular area are
         * prohibitively expensive.
         * </ul>
         * This means that for some {@code Shapes} this method might
         * return {@code false} even though the {@code Shape} contains
         * the rectangular area.
         * The {@link java.awt.geom.Area Area} class performs
         * more accurate geometric computations than most
         * {@code Shape} objects and therefore can be used if a more precise
         * answer is required.
         *
         * @param x the X coordinate of the upper-left corner
         *          of the specified rectangular area
         * @param y the Y coordinate of the upper-left corner
         *          of the specified rectangular area
         * @param w the width of the specified rectangular area
         * @param h the height of the specified rectangular area
         * @return {@code true} if the interior of the {@code Shape}
         *          entirely contains the specified rectangular area;
         *          {@code false} otherwise or, if the {@code Shape}
         *          contains the rectangular area and the
         *          {@code intersects} method returns {@code true}
         *          and the containment calculations would be too expensive to
         *          perform.
         * @see java.awt.geom.Area
         * @see #intersects
         * @since 1.2
         */
        public bool contains(double x, double y, double w, double h);
    }
}
